*** REPLICATION TOOLKIT ***

* AUTHORS: CIMINELLI DUVAL FURCERI 

* ARTICLE: EMPLOYMENT PROTECTION DEREGULATION AND LABOR SHARES IN ADVANCED ECONOMIES 

* JOURNAL: REVIEW OF ECONOMICS AND STATISTICS

* OUTPUT: TABLE G6 (Online Appendix)

***************************

cd ""

putexcel set "Tables/G6", modify 

global horizon 6 

************ PREPARE DATASET **********

run "Do files/Clean dataset"

* Bassanini, Nunziata, Venn (2009) layoff rates
gen b2 = layoff_US
gen b3 = -epsilon1
gen b4 = -epsilon1*layoff_US

* 0/1 variable if layoff rate above median
quietly sum layoff_rate, detail
local m = r(p50)
gen m2 = 1
replace m2 = 0 if layoff_rate < `m'
gen m3 = -epsilon1
gen m4 = -epsilon1*m2

* 2013 layoff rate
gen a2 = layoff_rate_3
gen a3 = -epsilon1
gen a4 = -epsilon1*layoff_rate_3

* Bassanini & Garnero layoff rate
gen u2 = jmr
gen u3 = -epsilon1
gen u4 = -epsilon1*jmr

* Normalize to show differential responses (75th and 25th percentiles)
foreach x in b m a u {
forvalues i = 2 / 4 {
quietly sum `x'`i', detail
local sc1 = r(p75)
local sc2 = r(p25)
gen r`i'`x' = (EPLregularworkers*`x'`i')/(`sc1'-`sc2')  
}
}

* Lags and forwards of explanatory variables
foreach x in b m a u {
forvalues s = 2/4 {
forvalues l = 1 / 6 {
gen l`l'r`s'`x' = l`l'.r`s'`x'
}
forvalues f = 1 / 5 {
gen f`f'r`s'`x' = f`f'.r`s'`x'
}
}
}

* Global for forward variables (Teulings and Zubanov)
foreach x in b m a u {
forvalues s = 2/4 {
global f1`s'`x'
global f2`s'`x' f1r`s'`x'
global f3`s'`x' f1r`s'`x' f2r`s'`x'
global f4`s'`x' f1r`s'`x' f2r`s'`x' f3r`s'`x'
global f5`s'`x' f1r`s'`x' f2r`s'`x' f3r`s'`x' f4r`s'`x'
global f6`s'`x' f1r`s'`x' f2r`s'`x' f3r`s'`x' f4r`s'`x' f5r`s'`x'
}
}

* EPL reform temporary contract, interacted with (alternative) industry-specific characteristics
foreach x in b m a u {
gen t2`x' = EPLtemporaryworkers*`x'2
gen t3`x' = EPLtemporaryworkers*`x'3
gen t4`x' = EPLtemporaryworkers*`x'4
}

************ ANALYSIS **********

forvalues s = 2/4 {
mat mat`s' = J(15,$horizon,.)

* Baseline
forvalues i= 1/$horizon {
quietly reghdfe  Y`i' r`s' l1Y l2Y l3Y l4Y l1r`s' l2r`s' l3r`s' l4r`s' t`s' ${f`i'`s'}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[1,`i'] = results[1,1]
mat mat`s'[2,`i'] = results[2,1]
mat mat`s'[3,`i'] = results[4,1]
* Bassanini, Nunziata Venn
quietly reghdfe  Y`i' r`s'b l1Y l2Y l3Y l4Y l1r`s'b l2r`s'b l3r`s'b l4r`s'b t`s' ${f`i'`s'b}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[4,`i'] = results[1,1]
mat mat`s'[5,`i'] = results[2,1]
mat mat`s'[6,`i'] = results[4,1]
* 0/1 variable if layoff rate above median
quietly reghdfe  Y`i' r`s'm l1Y l2Y l3Y l4Y l1r`s'm l2r`s'm l3r`s'm l4r`s'm t`s' ${f`i'`s'm}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[7,`i'] = results[1,1]
mat mat`s'[8,`i'] = results[2,1]
mat mat`s'[9,`i'] = results[4,1]
* 2013 layoff rate
quietly reghdfe  Y`i' r`s'a l1Y l2Y l3Y l4Y l1r`s'a l2r`s'a l3r`s'a l4r`s'a t`s' ${f`i'`s'a}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[10,`i'] = results[1,1]
mat mat`s'[11,`i'] = results[2,1]
mat mat`s'[12,`i'] = results[4,1]
* Bassanini & Garnero layoff rate
quietly reghdfe  Y`i' r`s'u l1Y l2Y l3Y l4Y l1r`s'u l2r`s'u l3r`s'u l4r`s'u t`s' ${f`i'`s'u}, absorb(id_cross_section i.year#id_country i.year#id_industry) cluster(ifscode year) nocons
matrix results = r(table)
mat mat`s'[13,`i'] = results[1,1]
mat mat`s'[14,`i'] = results[2,1]
mat mat`s'[15,`i'] = results[4,1]
}
}

************ SAVE OUTPUT **********

putexcel B4=matrix(mat2)
putexcel B21=matrix(mat4)
